home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Miami / MiamiSDK / netinclude / sys / time.h < prev    next >
C/C++ Source or Header  |  1997-12-04  |  2KB  |  80 lines

  1. #ifndef _SYS_TIME_H_
  2. #define _SYS_TIME_H_
  3.  
  4. #ifndef EXEC_TYPES_H
  5. #include <exec/types.h>
  6. #endif
  7.  
  8. #ifndef DEVICES_TIMER_H
  9. #include <devices/timer.h>
  10. #endif
  11.  
  12. /*
  13.  * Structure returned by gettimeofday(2) system call,
  14.  * and used in other calls.
  15.  */
  16.  
  17. struct compatible_timeval {
  18.   union {
  19.     long s_sec;
  20.     ULONG u_secs;
  21.   } mtv_sec;
  22.   union {
  23.     long s_usec;
  24.     ULONG u_micro;
  25.   } mtv_usec;
  26. };
  27.  
  28. #define timeval compatible_timeval
  29. #define tv_sec mtv_sec.s_sec
  30. #define tv_usec mtv_usec.s_usec
  31. #define tv_secs mtv_sec.u_secs
  32. #define tv_micro mtv_usec.u_micro
  33.  
  34. struct compatible_timerequest {
  35.     struct IORequest tr_node;
  36.     struct timeval tr_time;
  37. };
  38. #define timerequest compatible_timerequest
  39.  
  40. /*
  41.  * Structure defined by POSIX.4 to be like a timeval.
  42.  */
  43. struct timespec {
  44.     long    ts_sec;        /* seconds */
  45.     long    ts_nsec;    /* and nanoseconds */
  46. };
  47.  
  48. #define    TIMEVAL_TO_TIMESPEC(tv, ts) {                    \
  49.     (ts)->ts_sec = (tv)->tv_sec;                    \
  50.     (ts)->ts_nsec = (tv)->tv_usec * 1000;                \
  51. }
  52. #define    TIMESPEC_TO_TIMEVAL(tv, ts) {                    \
  53.     (tv)->tv_sec = (ts)->ts_sec;                    \
  54.     (tv)->tv_usec = (ts)->ts_nsec / 1000;                \
  55. }
  56.  
  57. #include "time.h"
  58.  
  59. struct timezone {
  60.     int    tz_minuteswest;    /* minutes west of Greenwich */
  61.     int    tz_dsttime;    /* type of dst correction */
  62. };
  63. #define    DST_NONE    0    /* not on dst */
  64. #define    DST_USA        1    /* USA style dst */
  65. #define    DST_AUST    2    /* Australian style dst */
  66. #define    DST_WET        3    /* Western European dst */
  67. #define    DST_MET        4    /* Middle European dst */
  68. #define    DST_EET        5    /* Eastern European dst */
  69. #define    DST_CAN        6    /* Canada */
  70.  
  71. /* Operations on timevals. */
  72. #define    timerclear(tvp)        (tvp)->tv_sec = (tvp)->tv_usec = 0
  73. #define    timerisset(tvp)        ((tvp)->tv_sec || (tvp)->tv_usec)
  74. #define    timercmp(tvp, uvp, cmp)                        \
  75.     (((tvp)->tv_sec == (uvp)->tv_sec) ?                \
  76.         ((tvp)->tv_usec cmp (uvp)->tv_usec) :            \
  77.         ((tvp)->tv_sec cmp (uvp)->tv_sec))
  78.  
  79. #endif /* !_SYS_TIME_H_ */
  80.